<template>
    <div class="common-layout">
        <el-container>
            <el-header>
                <Top :title="title" :sub-title="subTitle"></Top>
            </el-header>
            <el-main>
                <!-- 配置路由的二级出口 -->
                <RouterView></RouterView> 
            </el-main>
        </el-container>
    </div>
</template>

<script setup>
import { useRouter, RouterView } from 'vue-router'
import Top from '@/components/Top.vue'
import { ref } from 'vue';
let title = ref('管理员');
let subTitle = ref('兰州牛肉面');

// 通过useRouter方法获取到当前路由对象
const $router = useRouter()
// 从sessionStorage中获取登录信息
let loginInfo = sessionStorage.getItem('loginInfo')
if (!loginInfo) { 
    $router.push('/login')
}
loginInfo = JSON.parse(loginInfo)
if (loginInfo.businessName) {
    title.value = "商家"
    subTitle.value = loginInfo.businessName
} else { 
    title.value = "管理员"
    subTitle.value = ""
}





</script>

<style lang="less" scoped>
.common-layout,el-container{
    width: 100%;
    height: 100%;
}
.el-header{
    background-color: #fff;
    box-shadow: 0 1px 4px rgba(0,21,41,.08);
}
</style>